#ifndef __S51_IO_SPI_H__
#define __S51_IO_SPI_H__

#include "../../Core/Simple51core.h"
//#include "at89c55.h"

// #define pin_SCLK_1 pin_UC1701X_SCLK
// #define pin_MOSI_1 pin_UC1701X_MOSI
// #define pin_MISO_1 P70

#define pin_SCLK_1_HIGH
#define pin_SCLK_1_LOW
#define pin_MOSI_1_HIGH
#define pin_MOSI_1_LOW
#define pin_MISO_1_HIGH
#define pin_MISO_1_LOW
#define pin_MISO_1_READ
// #define pin_SCLK_2
// #define pin_MOSI_2
// #define pin_MISO_2

#define HSPI1 0
#define HSPI2 1

typedef struct
{
    uint8_t Speed;        /*速度*/
    uint8_t rxBuf;        /*发送缓冲*/
    uint8_t txBuf;        /*接收缓冲*/
    uint8_t SetCPOL : 1;  /**/
    uint8_t SetCPHA : 1;  /**/
    uint8_t BitOrder : 1; /**/
    uint8_t Mode : 1;     /*主机模式还是从机模式*/
    uint8_t Instance : 2; /*序号*/
    uint8_t nullbit : 2;
} SPI_HandleTypeDef;

void Simple51_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *_txData, uint16_t _size);
void Simple51_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *_rxData, uint16_t _size);
void Simple51_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *_txData, uint8_t *_rxData, uint16_t _size);

#endif